package main;


import java.util.Set;

import configuration.Config;
/**
 * container of all the information about the client
 * @author ran
 *
 */
public class UserInfo {
	private static UserInfo instance = new UserInfo();
	private String userName;
	private String pass;
	private String email;
	private Set<String> boxesList;
	private boolean isUpdate;
	private String path;
	private String computerName;
	/**
	 * @return the computer name
	 */
	public String getComputerName() {
		return computerName;
	}
	/**
	 * set the member computerName
	 * @param computerName the new value of the member
	 */ 
	public void setComputerName(String computerName) {
		this.computerName = computerName;
	}
	/**
	 * @return the location of DropBox folder
	 */
	public String getPath() {
		return path;
	}
	/**
	 * set the member path
	 * @param path the new value of the member
	 */
	public void setPath(String path) {
		this.path = path;
	}
	/**
	 * @return the true if client is update false otherwise
	 */
	public boolean isUpdate() {
		return isUpdate;
	}
	/**
	 * set the member isUpdate
	 * @param isUpdate the new value of the member
	 */
	public void setUpdate(boolean isUpdate) {
		this.isUpdate = isUpdate;
	}
	/**
	 * @return the email of the client
	 */
	public String getEmail() {
		return email;
	}
	/**
	 * set the member email
	 * @param email the new value of the member
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the folder list of the client
	 */
	public Set<String> getBoxesList() {
		return boxesList;
	}
	/**
	 * @return the computer name
	 */
	/*
	private String getBox(int index) {
		Iterator<String> it = boxesList.iterator();
		int i=0;
		while (it.hasNext()&&i<index) {
			it.next();
			i++;
		} 
		if(it.hasNext())
			return it.next();
		else
			return null;
	}*/
	/**
	 * set the member boxesList
	 * @param boxesList the new value of the member
	 */
	public void setBoxesList(Set<String> boxesList) {
		System.out.println("user Info set boxes : "+boxesList.size());
		this.boxesList = boxesList;
		System.out.println("user Info set boxes : "+this.boxesList.size());
	}
	/**
	 * add new folder to folder list
	 * @param boxName the name of the new folder
	 */
	public void addBox(String boxName) {
		System.out.println("user Info set boxes : "+boxesList.size());
		this.boxesList.add(boxName);
		System.out.println("user Info set boxes : "+this.boxesList.size());
	}
	/**
	 * @return the user name
	 */
	public String getUserName() {
		return userName;
	}
	/**
	 * set the member userName
	 * @param userName the new value of the member
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	/**
	 * @return the password
	 */
	public String getPass() {
		return pass;
	}
	/**
	 * set the member pass
	 * @param pass the new value of the member
	 */
	public void setPass(String pass) {
		this.pass = pass;
	}
	/**
	 * defult constructor of the class
	 */
	private UserInfo() {
	}
	/**
	 * 
	 * @return an instance of this class
	 */
	public static UserInfo getInstance(){
		return instance;
	}
	/**
	 * set the information according to config file
	 * @param configFile
	 */
	public void config(Config configFile) {
		this.userName = configFile.getUserName();
		this.pass = configFile.getPassword();
		this.email = configFile.getEmail();
		this.path = configFile.getDropBoxLocation();
		this.computerName = configFile.getComputerName();
		this.boxesList = configFile.getBoxList();
		
	}
	/**
	 * @return the information of user in config file
	 */
	public Config getConfig() {
		Config c= new Config();
		c.setUserName(userName);
		c.setPassword(pass);
		c.setBoxList(boxesList);
		c.setComputerName(computerName);
		c.setEmail(email);
		c.setDropBoxLocation(path);
		return c;
	}
	
}
